package com.xtoneict.auth.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.xtoneict.auth.entity.Role;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface RoleMapper extends BaseMapper<Role> {
    @Select("select role_id from user_role where user_id = #{arg0}")
    List<Integer> selectRoleIdByUserId(Integer userId);

    @Insert("insert into user_role (user_id, role_id) values (#{arg0}, #{arg1})")
    boolean insertUserAndRole(Integer userId, Integer roleId);

    @Delete("delete from user_role where user_id = #{arg0} and role_id = #{arg1}")
    boolean deleteUserAndRole(Integer userId, Integer roleId);
}
